#!/usr/bin/env python
# encoding: utf-8


"""
@file: budengshi_quyu.py
@time: 2017/5/9 上午9:16
"""
# 判断不等式表示的区域

from mathsolver.functions.base import *


# 判断不等式表示的区域在直线的什么地方
# Style1 Input paramer1:不等式 paramer2:直线方程
class BuDengShiBiaoShiDeQuyu(BaseFunction):
    def solver(self, *args):
        self.label.add('判断不等式表示的区域')
        arg1, arg2 = args
        ineq = arg1
        ineq_l, ineq_op, ineq_r = ineq.sympify()
        ineq_f = ineq_l - ineq_r
        eq = arg2
        # eq_l, eq_r = eq.sympify()
        # eq_f = eq_l - eq_r
        _x = sympify('x')
        _y = sympify('y')
        ineq_x_coef = ineq_f.coeff(_x)
        ineq_y_coef = ineq_f.coeff(_y)
        # eq_x_coef = eq_f.coeff(_x)
        # eq_y_coef = eq_f.coeff(_y)
        direct_text = ''
        if ineq_x_coef == 0 and ineq_y_coef > 0:
            if ineq_op.find('>') >= 0:
                direct_text = '上方'
            elif ineq_op.find('<') >= 0:
                direct_text = '下方'
        elif ineq_y_coef == 0 and ineq_x_coef > 0:
            if ineq_op.find('>') >= 0:
                direct_text = '右方'
            elif ineq_op.find('<') >= 0:
                direct_text = '左方'
        elif ineq_x_coef != 0 and ineq_y_coef != 0:
            if ineq_y_coef > 0 and ineq_op.find('>') >= 0:
                direct_text = '右上方'
            elif ineq_y_coef > 0 and ineq_op.find('<') >= 0:
                direct_text = '左下方'
            elif ineq_op.find('>') >= 0:
                direct_text = '右下方'
            else:
                direct_text = '左上方'
        self.steps.append(['不等式' + ineq.printing() + '表示的区域', '在直线' + eq.printing() + direct_text])
        return self


if __name__ == '__main__':
    _solve = BuDengShiBiaoShiDeQuyu().solver(BaseIneq(['x - 2*y + 6', '>', '0']), BaseEq(['x - 2*y + 6', '0']))
